function OCTgeturlparam(param) { var urlParams = new URLSearchParams(window.location.search); return urlParams.get(param) !== null ? param+'='+urlParams.get(param) : ''; } var OCT4_GET_LANG = ''; var prdoptmltcol_ur1201 = 'index.php?route=module/prdoptmltcol/'; var prdoptmltcol_url230 = 'index.php?route=extension/module/prdoptmltcol/'; var prdoptmltcol_url401 = 'index.php?route=extension/prdoptmltcol/module/prdoptmltcol|'; var prdoptmltcol_url402 = 'index.php?route=extension/prdoptmltcol/module/prdoptmltcol.'; var prdoptmltcol = { 'atgrid': function() { var product_ids = []; $("[onclick*='cart.add'], [onclick*='addToCart'], .product-thumb form input[name='product_id']").each(function() { if($(this).closest('form').find("[name*='product_id']").length) { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).val(); } else { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).attr('onclick').match(/[0-9]+/).toString(); } if(target.length && target.hasClass('prdoptmltcol_atgrid') == false) { target.addClass('prdoptmltcol_atgrid').addClass('prdoptmltcol_atgrid'+product_id); product_ids.push(product_id); } }); if(product_ids.length) { //console.log(product_ids.length); $.ajax({ url: prdoptmltcol_url230 + 'getcache' + OCT4_GET_LANG, type: 'post', data: {product_ids:product_ids}, cache: true, complete: function() { }, success: function(json) { if(json && json['grid']) { //console.log(json); $("[onclick*='cart.add'], [onclick*='addToCart'], .product-thumb form input[name='product_id']").each(function() { if($(this).closest('form').find("[name*='product_id']").length) { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).val(); } else { var target = $(this).closest('.product-thumb, .product-wrapper'); var product_id = $(this).attr('onclick').match(/[0-9]+/).toString(); } if(json['grid'][product_id] && target.length && target.hasClass('prdoptmltcol') == false) { target.addClass('prdoptmltcol').find('.price').after(json['grid'][product_id].join("")); } }); } } }); } }, 'prodpage': function() { var product_ids = []; var product_id = false; if($(".button-group-page input[name='product_id']").length) { product_id = $(".button-group-page input[name='product_id']").val(); product_ids.push(product_id); } else if($('#input-product-id').length) { product_id = $('#input-product-id').val(); product_ids.push(product_id); } else if($(".product-info input[name='product_id']").length) { product_id = $(".product-info input[name='product_id']").val(); product_ids.push(product_id); } else if($("#product input[name='product_id']").length) { product_id = $("#product input[name='product_id']").val(); product_ids.push(product_id); } if (product_ids.length) { $.ajax({ url: prdoptmltcol_url230 + 'getcache' + OCT4_GET_LANG, type: 'post', data: {product_ids:product_ids}, cache: true, complete: function() { }, success: function(json) { if(json && json['prdpg']) { var target = $('#product .form-group').eq(0); var target_OC4 = $('#product .mb-3').eq(0); var target_J2 = $('#product .form-group').eq(0); var target_J3 = $('.button-group-page'); if(json['prdpg'][product_id]) { if(target.length && target.hasClass('prdoptmltcol') == false) { target.addClass('prdoptmltcol').before(json['prdpg'][product_id].join("")); } if(target_J2.length && target_J2.hasClass('prdoptmltcol') == false) { target_J2.addClass('prdoptmltcol').before(json['prdpg'][product_id].join("")); } if(target_J3.length && target_J3.hasClass('prdoptmltcol') == false) { target_J3.addClass('prdoptmltcol'); if($('.product-options h3.options-title').length) { $('.product-options h3.options-title').after(json['prdpg'][product_id].join("")); } else { target_J3.before('
'); } } if(target_OC4.length && target_OC4.hasClass('prdoptmltcol') == false) { target_OC4.addClass('prdoptmltcol').before(json['prdpg'][product_id].join("")); } } } } }); } }, 'initjson': function() { prdoptmltcol.atgrid(); $(document).ajaxStop(function() { prdoptmltcol.atgrid(); }); prdoptmltcol.prodpage(); } } $(document).ready(function() { prdoptmltcol.initjson(); // FOR GRID LIST $(document).delegate('.prdoptmltcol_radio_griddiv', 'click', function() { if($(this).find('input[type="checkbox"]').length) { if($(this).find('input[type="checkbox"]').prop('checked')) { $(this).find('.prdoptmltcol_atgrid').removeClass('act'); $(this).find('input[type="checkbox"]').prop("checked",false).trigger('change'); } else { $(this).find('.prdoptmltcol_atgrid').addClass('act'); $(this).find('input[type="checkbox"]').prop("checked",true).trigger('change'); } } else { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).find('.prdoptmltcol_atgrid').addClass('act'); $(this).find('input[type="radio"]').prop("checked",true).trigger('change'); } var grdimg = $(this).find('.prdoptmltcol_swpimggrd').val(); var target = $(this).closest('.product-thumb, .product-wrapper').find('.image'); if(grdimg != '') { target.find('img.img-responsive, img.img-fluid, img.first-image').attr('src', grdimg); target.find('img.img-responsive, img.img-fluid, img.first-image').attr('srcset', grdimg); target.find('img.img-responsive, img.img-fluid, img.first-image').parent().removeClass('has-second-image'); } }); $(document).delegate('.prdoptmltcol_gridbtnrst', 'click', function() { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).closest('.form-group, .mb-3').find('input.prdoptmltcol_radio_input').prop("checked",false).trigger('change'); var orgimg = $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_orgimggrd').val(); var target = $(this).closest('.product-thumb, .product-wrapper').find('.image'); target.find('img.img-responsive, img.img-fluid, img.first-image').attr('src', orgimg); target.find('img.img-responsive, img.img-fluid, img.first-image').attr('srcset', orgimg); target.find('img.img-responsive, img.img-fluid, img.first-image').parent().removeClass('has-second-image'); }); // FOR Product Details Page $(document).delegate('.prdoptmltcol_radio_prdpgdiv', 'click', function() { if($(this).find('input[type="checkbox"]').length) { if($(this).find('input[type="checkbox"]').prop('checked')) { $(this).find('.prdoptmltcol_atprd').removeClass('act'); $(this).find('input[type="checkbox"]').prop("checked",false).trigger('change'); } else { $(this).find('.prdoptmltcol_atprd').addClass('act'); $(this).find('input[type="checkbox"]').prop("checked",true).trigger('change'); } } else { $(this).closest('.form-group, .mb-3').find('.act').removeClass('act'); $(this).find('.prdoptmltcol_atprd').addClass('act'); $(this).find('input[type="radio"]').prop("checked",true).trigger('change'); } if($(this).find('.prdoptmltcol_atprd').attr('data-original-title')) { $(this).closest('.form-group, .mb-3').find('.prdoptmltcol_showtitle').remove(); $(this).closest('.form-group, .mb-3').find('label').after('